home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17979 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news.cern.ch!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: sizeof() question >>> :)
  5. Date: 18 Apr 96 10:25:23 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.829823123@news.cern.ch>
  8. References: <1996Apr12.061927@topaz> <31714828.1574068@news.linex.com> <4l0dcr$14t0@darwin.nbnet.nb.ca> <danpop.829678939@news.cern.ch> <4l4fik$1a8_005@donstarr.best.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: NN version 6.5.0 #18 (NOV)
  14.  
  15. In <4l4fik$1a8_005@donstarr.best.com> super@donstarr.org (Don Starr) writes:
  16.  
  17. >In article <danpop.829678939@news.cern.ch>,
  18. >   danpop@mail.cern.ch (Dan Pop) wrote:
  19. >*>
  20. >*> If you allocate the space for the array you can call one of the memory
  21. >*> routines which return the size of the allocation.
  22. >*> Dave Gaudet via Rick Bruce
  23. >*
  24. >*There is no such "routine" in the C language.
  25. >*
  26. >*Dan
  27. >
  28. >Technically, there is no such _any_ routine in the C language. The language 
  29. >doesn't define any functions - "standard" libraries do.
  30.  
  31. When you use the word "technically", check that your statement is 
  32. technically correct, first.  The standard (no need for quotes here)
  33. C library specification is a part of the C language definition.
  34. Check the ISO/IEC 9899:1990 standard for further enlightment.
  35.  
  36. >As to the original question, if you know how your heap is structured (from 
  37. >the source to your malloc(), new, or whatever), you can get the size of any 
  38. >allocation from it.
  39.  
  40. "Technically" bullshit, although it might work in practice, for a given
  41. platform and implementation version.  The code could crash and burn even
  42. when upgrading to the next version.
  43.  
  44. Any attempt to access memory outside of an allocated block results in
  45. undefined behaviour.  Check the above mentioned standard if you don't
  46. know already what this means.
  47.  
  48. Dan
  49. --
  50. Dan Pop
  51. CERN, CN Division
  52. Email: danpop@mail.cern.ch 
  53. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  54.